package apple.core;

public class Utilities {

   /**
    * Calculate a 16-bit address from a base 16-bit address and an unsigned
    * 8-bit offset.
    * 
    * @param base
    *           a 16-bit base address
    * @param offset
    *           an unsigned 8-bit offset
    * @return the resulting 16-bit address
    */
   public static short getAddress(short base, byte offset) {
      int unsignedOffset = offset & 0xFF;
      short address = (short) (base + unsignedOffset);
      return address;
   }

   /**
    * Create a 16-bit word from a high-order byte and a low-order byte.
    * 
    * @param highByte
    *           the most significant byte
    * @param lowByte
    *           the least significant byte
    * @return the resulting 16-bit word
    */
   public static short getWord(byte highByte, byte lowByte) {
      int word = (highByte << 8) | (lowByte & 0xFF);
      return (short) word;
   }
}
